//
//  LZMyTicketCell.m
//  DoctorFAQs
//
//  Created by langZai on 2017/2/13.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "LZMyTicketCell.h"

@implementation LZMyTicketCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = KHColorFromRGB(0xf8f8f8);
        // 背景图片
        UIImageView *backImageView = [[UIImageView alloc] init];
        backImageView.image = [UIImage imageNamed:@"icon_Coupon"];
        [self addSubview:backImageView];
        [backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.size.sizeOffset(CGSizeMake(355, 100));
//            make.center.equalTo(self);
//            make.width.offset(355*xsIZE);
            make.left.equalTo(self).offset(10*xsIZE);
            make.right.equalTo(self).offset(-10*ysIZE);
            make.height.offset(100*ysIZE);
            make.top.equalTo(self);
        }];
        
        // 状态图片
        UIImageView *stateImageView = [[UIImageView alloc] init];
        stateImageView.image = [UIImage imageNamed:@"icon_state"];
        [backImageView addSubview:stateImageView];
        [stateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.offset(12*xsIZE);
            make.height.offset(12*ysIZE);
            make.left.equalTo(backImageView.mas_left).offset(10*xsIZE);
            make.top.equalTo(backImageView.mas_top).offset(31*ysIZE);
        }];
        
        // 状态
        UILabel *stateLabel = [[UILabel alloc] init];
        stateLabel.text = @"状态";
        stateLabel.font = NEWFONT(12);
        [stateLabel sizeToFit];
        stateLabel.textColor = KHColorFromRGB(0x666666);
        [backImageView addSubview:stateLabel];
        [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(stateImageView);
            make.left.equalTo(stateImageView.mas_left).offset(20*xsIZE);
        }];
        
        //可使用
        _canUseLabel = [[UILabel alloc]init];
        _canUseLabel.text = @"可使用";
        _canUseLabel.font = NEWFONT(12);
        _canUseLabel.textColor = KHColorFromRGB(0x666666);
        _canUseLabel.textAlignment = NSTextAlignmentLeft;
        [backImageView addSubview:_canUseLabel];
        [_canUseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(stateLabel.mas_right).offset(10*xsIZE);
            //make.top.equalTo(backImageView.mas_top).offset(31);
            make.centerY.equalTo(stateImageView);
        }];
        
        //注意图片
        UIImageView *warningImageView = [[UIImageView alloc] init];
        warningImageView.image = [UIImage imageNamed:@"icon_careful"];
        [backImageView addSubview:warningImageView];
        [warningImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.offset(12*xsIZE);
            make.height.offset(12*ysIZE);
            make.bottom.equalTo(backImageView).offset(-31*ysIZE);
            make.left.equalTo(backImageView).offset(10*xsIZE);
        }];
        
        // 注意Label
        UILabel *warningLabel = [[UILabel alloc] init];
        warningLabel.text = @"注意";
        warningLabel.font = NEWFONT(12);
        warningLabel.textColor = KHColorFromRGB(0x666666);
        [backImageView addSubview:warningLabel];
        [warningLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(warningImageView.mas_left).offset(20*xsIZE);
            make.centerY.equalTo(warningImageView);
        }];
        
        // 咨询医生每次使用张数
        _userNumLabel = [[UILabel alloc] init];
        _userNumLabel.text = @"咨询医生每次仅限使用一张";
        _userNumLabel.font = NEWFONT(12);
        _userNumLabel.textColor = KHColorFromRGB(0x666666);
        _userNumLabel.textAlignment = NSTextAlignmentLeft;
        [backImageView addSubview:_userNumLabel];
        [_userNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(warningLabel.mas_right).offset(10*xsIZE);
            make.centerY.equalTo(warningLabel);
        }];
        
        // 金额Label
        _moneyLabel = [[UILabel alloc] init];
        [backImageView addSubview:_moneyLabel];
        _moneyLabel.text = @"7元";
        _moneyLabel.textColor = KHColorFromRGB(0xffffff);
        _moneyLabel.font = NEWFONT(39);
        [_moneyLabel sizeToFit];
        _moneyLabel.textAlignment = NSTextAlignmentLeft;
        [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.right.equalTo(self.mas_right).offset(-18 *xsIZE);
        }];
        
    }
    return self;
}

// 赋值
- (void)setTicketModel:(LZTicketModel *)ticketModel {
    _ticketModel = ticketModel;
    _moneyLabel.text = [NSString stringWithFormat:@"%@元",_ticketModel.money];
}

@end
